<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h2>距离跳转的页面还有<span id="box">5</span>秒</h2>
    <script>
        var span = document.getElementById('box');
        var num = 5;
        var time = setInterval(function() {
            num--;
            span.innerHTML = num;
            if (num == 1) {
                location.href = 'http://www.baidu.com';
                clearInterval(time);
            }
        }, 1000)
    </script>
</body>

</html>